/*
 * =====================================================================================
 *
 *       Filename:  epoll.h
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  07/23/2012 09:37:00 PM
 *       Revision:  none
 *       Compiler:  gcc/g++
 *
 *         Author:  wangtengchao , wangtengchao AT gmail.com
 *   Organization:  
 *
 * =====================================================================================
 */

#ifndef EPOLL_H
#define EPOLL_H
#include "demultiplexer.h"
#ifdef linux
#include<sys/epoll.h>
#include<vector>
namespace inm
{
    namespace net
    {
        class Dispatcher;

        typedef std::vector<struct epoll_event> EpollEventVector;
        const static int InitialMaxEvents = 10;//initial max events.use vector so can be changed
        class Epoll : public Demultiplexer
        {
        public:
            Epoll();
            ~Epoll();//should close epfd
             void registerEvent(int fd,const short& et);
             void updateEvent(int fd,const short& et);
             void removeEvent(int fd, const short& et);
             void handleEvents(int timeout);
             void quit();

        private:
            int epfd_;//for epoll_create
            EpollEventVector epollEventVector_;
        };
    };
};
#else
namespace inm
{
    namespace net
    {
        class Dispatcher;
        class Epoll : public Demultiplexer
        {
        public:
            Epoll(){}
            ~Epoll(){}
             void registerEvent(int fd,const short& et){}
             void updateEvent(int fd,const short& et){}
             void removeEvent(int fd, const short& et){}
             void handleEvents(int timeout){}
             void quit(){}

        };
    };
};
#endif //linux
#endif //EPOLL_H
